package com.banciyuan.bcywebview.biz.post.write.series;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;

import java.util.List;

import de.greenrobot.daoexample.model.MySeriesItem;

/**
 * Created by hy on 2016/1/5.
 */
public class SelectSeriesAdapter extends BaseAdapter {
    private List<MySeriesItem> list;
    private Context context;
    private LayoutInflater layoutInflater;

    public SelectSeriesAdapter(Context context, List<MySeriesItem> list) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (null == convertView) {
            viewHolder = new ViewHolder();
            convertView = layoutInflater.inflate(R.layout.myseries_item, parent, false);
            viewHolder.tvSeriesName = (TextView) convertView.findViewById(R.id.tv_seriesname);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvSeriesName.setText(Html.fromHtml(list.get(position).getTitle()));
        return convertView;
    }

    static class ViewHolder {
        TextView tvSeriesName;
    }
}
